package com.ssm.pojo.vo;

import lombok.Data;

/*
统一结果集处理类
 */
@Data
public class Result<T> {
    private Integer code;
    private String message;
    private T data;
    public Result(){

    }
    public static <T> Result<T> success(T data){
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMessage("操作成功");
        result.setData(data);
        return result;
    }
    public static <T> Result<T> success(Integer code,T data){
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMessage("操作成功");
        result.setData(data);
        return result;
    }
    public static <T> Result<T> success(Integer code ,T data,String message){
        Result<T> result = new Result<>();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }
    public static <T> Result<T> error(Integer code ,String message){
        Result<T> result = new Result<>();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
}
